/**
 * 
 */
package cn.zhucongqi;

import java.util.List;

import com.jfinal.ext2.core.ControllerExt;
import com.jfinal.ext2.upload.filerenamepolicy.DateRandomFileRenamePolicy;
import com.jfinal.upload.UploadFile;

/**
 * @author BruceZCQ
 * Jun 22, 20154:55:18 PM
 */
public class UploadController extends ControllerExt {

	public void index(){
		
	String parent = "BruceZCQ";
		
		DateRandomFileRenamePolicy policy = new DateRandomFileRenamePolicy(parent); 
		
		List<UploadFile> files = this.getFiles(policy);
		
		StringBuilder sb = new StringBuilder();
		for (UploadFile file : files) {
			
			String info = "origin==>"+file.getFileName()+
					"\nFileSavePath=>"+policy.getAppParentDateDir()+
					"\n path =>"+file.getFile().getAbsolutePath()
					+ "\n db info >>"+policy.getAppParentDateDir()+file.getFileName();
			sb.append("\n\n\n").append(info);
		}
		this.renderText(sb.toString());
		
//		UploadFile file = this.getFile("img", policy);
		
		//		UploadFile file = this.getFile("img", new CustomParentDirFileRenamePolicy("BruceZCQ",NamePolicy.ORIGINAL_NAME));
//		this.renderText("origin==>"+file.getOriginalFileName()+"path=>"+file.getFile().getAbsolutePath());
	}
	
//	public void dateFileRenampolicy(){
//		DateRandomFileRenamePolicy policy = new DateRandomFileRenamePolicy("group"); 
//		UploadFile file = this.getFile("img", policy);
//		//this.renderText("origin==>"+file.getOriginalFileName()+"\npath=>"+file.getFile().getAbsolutePath()+"\nFileSavePath=>"+policy.getFileSavePath());
//	}
}
